package com.wn.controller;

import com.common.entity.Hotel;
import com.common.entity.Hotelroomitem;
import com.common.entity.PageParam;
import com.common.entity.Rsp;
import com.wn.service.HotelRoomItemServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class HotelRoomItemController {

    @Autowired
    HotelRoomItemServiceImpl hotelRoomItemService;

    //    @SystemControllerLog(description = "分页查询用户信息")
    @PostMapping("/searchSomeHotelroomitemByPage")
//    @RequireRoles(roles = {"admin","super_admin","reception","guide","tourist"},index = 1)
    @ApiOperation("查询所有 支持 多条件 分页 排序 查询")
    public Rsp searchSomeByPage(@RequestBody PageParam<Hotelroomitem> hotelroomitemPageParam, @RequestHeader("token") String token) {

        return Rsp.success(hotelRoomItemService.searchSomeByPage(hotelroomitemPageParam));
    }

    @PostMapping("/addOneitem")
    @ApiOperation("添加")
    public Rsp addOneitem(@RequestBody Hotelroomitem hotelroomitem,@RequestHeader("token") String token){
        System.out.println(hotelroomitem.toString());
        return hotelRoomItemService.addOne(hotelroomitem);
    }

    @PostMapping("/updateitem")
    @ApiOperation("修改")
    public Rsp updateitem(@RequestBody Hotelroomitem hotelroomitem,@RequestHeader("token") String token){
        System.out.println(hotelroomitem.toString());
        return hotelRoomItemService.update(hotelroomitem);
    }
//
    @PostMapping("/deleteLogicalitem")
    @ApiOperation("逻辑删除")
    public Rsp deleteLogicalitem(@RequestBody Hotelroomitem hotelroomitem){
        return hotelRoomItemService.deleteLogical(hotelroomitem);
    }

    @GetMapping("getByIdAll")
    @ApiOperation("根据id查询对应的房间")
    public List<Hotelroomitem> getByIdAll(Hotelroomitem hotelroomitem,@RequestHeader("token") String token){
        return hotelRoomItemService.getByIdAll(hotelroomitem.getId());
    }
}
